package delayQueue.test

import delayQueue.{DelayJob, ExecuteDelayJob}
import org.redisson.Redisson
import org.redisson.api.RedissonClient
import org.redisson.config.Config

class ExecutorTask() extends ExecuteDelayJob {

  override val delayQueueName: String = "message_delay_queue"

  override val client: RedissonClient = {
    val config = new Config
    config.useSingleServer.setAddress("redis://192.168.3.183:6379")
    val redissonClient = Redisson.create(config)
    redissonClient
  }

  override def execute(job: DelayJob): Unit = {
    val messageId = job.param.get("messageId").getOrElse(throw new Exception("Can not found messageId.")).asInstanceOf[Int]
    val customerIds = job.param.get("customerIds").getOrElse(throw new Exception("Can not found customerIds.")).asInstanceOf[List[Int]]

    println("messageId:" + messageId + "customerIds:" + customerIds.mkString)

  }
}
